In computing, a hang or freeze occurs when either a single computer program, or the whole system ceases to respond to inputs. In the most commonly encountered scenario, a workstation with a graphical user interface, all windows belonging to the frozen program become static, and though the mouse cursor still moves on the screen, neither typing on the keyboard nor clicking the mouse produces any effect in the program's windows. The mouse cursor may also be stuck in a form indicating that it is waiting for some operation to complete, such as an hourglass or a spinning wait cursor. Many modern operating systems provide the user with a means to terminate a hung program without rebooting or logging out. In more severe hangs affecting the whole system, no window belonging to any program will respond to keyboard or mouse input, and often the mouse cursor will freeze in place on the screen. Almost always, the only way to recover from a system freeze is to reboot the machine, usually by power cycling with an on/off or reset button. In the Windows 7 and Windows Vista operating systems, hangs almost always precedes a Blue Screen of Death or are a sign to the user that one is on its way. On Windows systems, if clicked on, a hanging program will gain "Not Responding" in parentheses on its top bar.
A hang differs from a crash, in which a program exits abnormally or the operating system shuts down.
Hangs are not limited to client personal computers with a graphical user interface, as in the example above. Servers can hang as well. In those cases, the server ceases to respond to requests. These sorts of hangs are typically addressed by a solution far more complex than an on/off or reset button.
Pre-emptive multitasking operating systems, such as Microsoft Windows 2000/XP/Vista/7, Apple Computer's Mac OS X and Linux hang less often as the multi-tasking system is not affected by non-terminating loops and further does not require tasks to yield control to the operating system. If a task does hang, the scheduler may switch to another group of interdependent tasks so that all processes will not hang.[1]
Contents |
Hardware can cause a computer to hang, either because it is intermittent or because it is mismatched with other hardware in the computer[2] (this can occur when one makes an upgrade). Hardware can also become defective over time due to dirt or heat damage.
A hang can also occur due to the fact that the programmer has incorrect termination conditions for a loop, or, in a co-operative multitasking operating system, forgetting to yield to other tasks. Said differently, many software-related hangs are caused by threads waiting for an event to occur which will never occur.[3] This is also known as an infinite loop.
Another cause of hangs is a race condition in communication between processes. One process may send a signal to a second process then stop execution until it receives a response. If the second process is busy the signal will be forced to wait until the process can get to it. However, if the second process was busy sending a signal to the first process then both processes would wait forever for the other to respond to signals and never see the other’s signal (this event is known as a deadlock). If the processes are uninterruptible they will hang and have to be shut down. If at least one of the processes is a critical kernel process the whole system may hang and have to be restarted.
A computer may seem to hang when in fact it is simply processing very slowly. This can be caused by too many programs running at once, not enough memory (RAM), or memory fragmentation, slow hardware access (especially to remote devices), slow system APIs, etc. It can also be caused by hidden programs which were installed surreptitiously, such as spyware.
In many cases programs may appear to be hung, but are making slow progress, and waiting a few minutes will allow the task to complete.
Usually, in systems with a modern operating system, the user is able to terminate the programs running (for instance, with the kill command, or through the "end task" button on the task list in recent versions of Microsoft Windows), and, if they wish, restart it in the hope that the anomalous condition that caused the hang does not recur. Older systems, such as those using MS-DOS or Windows 3.1x, often needed to be completely restarted in the event of a hang.
A watchdog timer can reboot the computer in the event of a hang (this is commonly used in embedded devices).